package dao

import "blog/model"

var ArticleExtendDao = &articleExtendDao{}

type articleExtendDao struct {
}

// 查询文章扩展信息
func (dao articleExtendDao) ArticleExtendGet(id interface{}) (*model.ArticleExtend, bool) {
	mod := &model.ArticleExtend{}
	switch val := id.(type) {
	case int:
		has, _ := Db.Where("atc_id=?", val).Get(mod)
		return mod, has
	default:
		return mod, false
	}
}

// 更新文章扩展信息
func (dao articleExtendDao) ArticleExtendUpdate(extend *model.ArticleExtend) error {
	sess := Db.NewSession()
	if _, err := Db.ID(extend.AtcId).Update(extend); err != nil {
		return sess.Rollback()
	}
	return sess.Commit()
}
